import { ColumnProps } from "@/components/Table/type";
import { SchemaProps } from "@/components/Form/type";
export const sexList = [
  { label: "男", value: 0 },
  { label: "女", value: 1 }
];
export const statusList = [
  { label: "正常", value: 0 },
  { label: "停用", value: 1 }
];
export const columns: ColumnProps[] = [
  { type: "index", label: "#", width: 50 },
  { prop: "userName", label: "账号", search: { el: "input" } },
  { prop: "nickName", label: "昵称", search: { el: "input" } },
  { prop: "phone", label: "手机号", search: { el: "input" } },
  { prop: "deptName", label: "部门" },
  {
    prop: "sex",
    label: "性别",
    width: 100,
    render: ({ row }) => {
      for (const sex of sexList) {
        if (sex.value === row["sex"]) {
          return sex.label;
        }
      }
    }
  },
  {
    prop: "status",
    label: "状态",
    width: 100,
    render: ({ row }) => {
      for (const status of statusList) {
        if (status.value === row["status"]) {
          return status.label;
        }
      }
    }
  },
  { prop: "action", label: "操作", width: 150, fixed: "right" }
];

export const schemas: SchemaProps[] = [
  {
    field: "userName",
    label: "账号",
    required: true,
    disabled: row => {
      return !!row.id;
    }
  },
  { field: "nickName", label: "昵称", required: true },
  { field: "phone", label: "手机号", required: true },
  { field: "deptId", label: "部门", required: true },
  { field: "roleIds", label: "角色" },
  { field: "postIds", label: "岗位" },
  {
    field: "sex",
    label: "性别",
    el: "radio-button-group",
    elProps: {
      options: sexList
    },
    defaultValue: 0
  },
  {
    field: "status",
    label: "状态",
    el: "switch",
    elProps: {
      inlinePrompt: true,
      activeText: "停用",
      inactiveText: "正常",
      activeValue: 1,
      inactiveValue: 0
    },
    defaultValue: 0
  }
];
